package com.lws.hellojms.module.jms.service;

import com.lws.hellojms.module.jms.MessageFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.stereotype.Service;

/**
 * Created by Administrator on 2016/3/14.
 */
@Service
public class JMSService {

    @Autowired
    @Qualifier("jmsQueueTemplate")
    private JmsTemplate jmsQueueTemplate;
    @Autowired
    @Qualifier("jmsTopicTemplate")
    private JmsTemplate jmsTopicTemplate;

    public void sendMessage(String destination, final String message) {
        jmsQueueTemplate.send(destination, MessageFactory.createInstance(message));
    }

    public void publishTopic(String destination, final String message) {
        jmsTopicTemplate.send(destination, MessageFactory.createInstance(message));
    }

}
